package com.leeon.generics;


class ClassAsFactory<T>{
	T x;
	public ClassAsFactory(Class<T> kind){
		try {
			x = kind.newInstance();
		} catch (InstantiationException | IllegalAccessException e) {
			throw new RuntimeException();
		}
	}
}

class Employee{}

public class InstantiateGenericType {
	public static void main(String[] args){
		ClassAsFactory<Employee> fe = new ClassAsFactory<Employee>(Employee.class);
		System.out.println("class as factory <Employee> success");
		try {
			ClassAsFactory<Integer> fi = new ClassAsFactory<Integer>(Integer.class);
		} catch (Exception e) {
			System.out.println("faild");
		}
	}
}
